package com.ljd.controller;


import com.ljd.entity.subject.OneSubject;
import com.ljd.service.EduSubjectService;
import com.ljd.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author ljd
 * @since 2021-12-02
 */
@RestController
@RequestMapping("/eduservice/subject")
//@CrossOrigin
@Api(description = "课程分类管理")
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    @ApiOperation(value = "Excel批量导入")
    @PostMapping("saveSubject")
    public R saveSubject(MultipartFile file){
        subjectService.saveSubject(file,subjectService);
        return R.ok();
    }
    @ApiOperation(value = "查询课程分类列表")
    @GetMapping("getAllSubject")
    public R getAllSubject() {
       List<OneSubject> subjects = subjectService.getAllSubject();
       return R.ok().data("list",subjects);
    }

}

